/**
 * @UiSizer.cpp
 * Copyright 2013 (C) FatalEror / Dean Bahari
 * 
 * UiPack is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * See LICENSE file in main folder for more information.
 */

#ifndef _UI_SIZER_HPP_
#define _UI_SIZER_HPP_

class UiWindow;
class UiToolWindow;

struct UiSizerItem {
	UiBase        *mHandle;
	short          mWidth;
	short          mHeight;
	bool           mIsSizer;
	unsigned short mAlignType;
	RECT           mMargin;
	RECT           mRect;
};

class UiSizer : public UiBase {
	int                      mType;
	std::vector<UiSizerItem> mItem;
	int                      mCurrentItem;
public:
	UiSizer(int type = UiSizer::UI_SIZER_HORIZONTAL);
	UiSizer(UiBase *holder, int type = UiSizer::UI_SIZER_HORIZONTAL);

	void setHolder(UiBase *holder);
	void handleResize(int width, int height);

	UiSizer &attach(UiSizer *sizer);
	UiSizer &attach(UiBase *item);
	UiSizer &attach(UiToolWindow *window);
	UiSizer &setMargin(int left, int top, int right, int bottom);
	UiSizer &setSize(int width, int height);
	UiSizer &setAlign(int type);

	enum Type {
		UI_SIZER_HORIZONTAL,
		UI_SIZER_VERTICAL,
		UI_SIZER_GRID,
		UI_SIZER_ALIGN_LEFT   = 0x01,
		UI_SIZER_ALIGN_CENTER = 0x02,
		UI_SIZER_ALIGN_RIGHT  = 0x04,
		UI_SIZER_ALIGN_TOP    = 0x10,
		UI_SIZER_ALIGN_MIDDLE = 0x20,
		UI_SIZER_ALIGN_BOTTOM = 0x40,
	};
};

#endif//_UI_SIZER_HPP_